#ifndef AI_INSTANT_H
#define AI_INSTANT_H

#include <QWidget>
#include <QMutex>
#include <QFile>

#include "configuredialog.h"
#include "bdaqctrl.h"
#include "simplegraph.h"
#include "report.h"

namespace Ui {
class Ai_Instant;
}

class Ai_Instant : public QDialog
{
    Q_OBJECT

public:
    explicit Ai_Instant(QWidget *parent = nullptr);
    ~Ai_Instant();

    void Initialize();
    void ConfigureDevice();
    void ConfigureGraph();
    void CheckError(ErrorCode errorCode);
    void RefreshList();
    void SetConfigureDialog(ConfigureDialog *dialog){this->configDialog = dialog;}
    void SetConfigureParameter(ConfigureParameter value){this->configure = value;}
    double Round(double dVal,int iPlace);
    double ValueToWeight_0(double value);
    double ValueToWeight_1(double value);


private slots:
//    void on_btnConfigure_clicked();

    void on_btnStart_clicked();

    void on_btnPause_clicked();

    void on_btnStop_clicked();

    void on_sldTimerValue_valueChanged(int value);

    void TimerTicked();

    void on_edtTimeValue_returnPressed();

    void slot_LCDTimeOut();
    void slot_dampingTimeOut();

    void on_btnBack_clicked();

    void on_move_lineEdit_textChanged(const QString &arg1);


    void on_report_toolButton_clicked();

private:
    Ui::Ai_Instant *ui;
    SimpleGraph *graph;
    ConfigureDialog *configDialog;
    ConfigureParameter configure;
    InstantAiCtrl *instantAiCtrl;//关键
    double scaledData[16];//通道数据
    QTimer *timer;
    QTimer *LCDtimer;
    QTimer *dampingTimer;
    int OriTrainTime;
    int OriX;
    const double DAMPING = 0.5;//阻尼因子.

    QVector<double> xVector;

    void countX(QVector<double> x);


};

#endif // AI_INSTANT_H
